/**
 * LocalStorageUtil操作工具类
 */
export default class LSU {


    public static get(key: string){
        return localStorage.getItem(key);
    }

    /**
     * 从本地存储获取数字, 如果本地存储中不存在该key, 则返回1, 并且将1存储到本地存储中, 使用key
     * @param key
     */
    public static getNumber(key: string){
        const num = localStorage.getItem(key);
        if (num){
            return Number(num);
        }else {
            localStorage.setItem(key, "1");
            return 1;
        }
    }

    public static getString(key: string){
        return localStorage.getItem(key) ?? "";
    }

    public static set(key: string, value: string){
        localStorage.setItem(key, value);
    }
}
